I'd like to insert a pending order in my expert advisor on MT4. Here is an example
OrderSend(Symbol(),OP_BUY,1.4,Ask,0,Ask-0.002,Ask+0.004,"Ordine di esempio",123,"expiration date",clrAliceBlue);
Now the problem is that i'd like to set a expiration date. If I put 0 it doesn't expire. But if I'd like to expire it in 2018.07.22 how can I do?
Furthermore can I insert in the same expert advisor 2 OrderSend?
You can create an expiring order if it is not market. So cancel or kill at expiration. If the order is market, it cannot expire, you have to close it by OrderClose() function when the time is right.
In order to set some expiration time, you have to pass datetime/integer (seconds) value of it. Something like datetime expiry=StrToTime("2018.07.22 00:00") and then pass expiry parameter in the OrderSend() function; alternative way is to create a timer or check to cancel each tick.
Related
We plan to synchronize the resource calendar using the "calendarView delta" method (https://learn.microsoft.com/en-us/graph/api/event-delta?view=graph-rest-1.0&tabs=http).
We have found that it is possible to synchronize a calendar without specifying a start and end date, but for now this feature is in beta.
What is the best way to retrieve the events of a future period, while time is running? For example, if we want to retrieve the events of the coming year, we need to create a delta [today, year +1], but next month this delta, encrypted in the token, will represent the period [month -1, month + 11] .
We thought of a solution that would consist in renewing the token every month, but this has two drawbacks: it forces us to run a full synchronization once a month for all synchronized resources, and we don't really synchronize a sliding one-year window.
I have an aggregation that looks at a sliding 30-day window (1 day period) of customer purchases, keyed by customer id, with the value being the purchase amount. I sum up the values by key, thus getting the aggregate purchase amount for each customer during the last 30 days. I store this number in a customer record in an external database.
My question is this: if a customer hasn't purchased anything in the last 30 days, how do I automatically reset the customer record to a default value, in this case zero? I'd prefer to keep all my logic in Dataflow and avoid doing too much work, since this will need to scale quite a bit. I'm basically looking for a way to automatically get a key-value for each key that was not in the current window but was in the last, and the value being a potentially configurable default.
Trying to answer my own question, but hoping for feedback as to whether this solution would scale:
I've thought about having a step after the initial window-and-sum. This transform would receive (customerId, purchaseSum) elements once a day, as the result of the 30-day window sum is made available. Since these elements are timestamped (with the timestamp of the most recent input element, I believe) I can re-window them. If I create a two-day window with a one-day period, I would then be able to group by key and process (customerId, [purchaseSumA, purchaseSumB]) for customers that had a purchase both in the last 30 days and in the last 31 days. In this case, I emit purchaseSumB. However, if there's only in element in the list, and the timestamp indicates that the purchase was made 31 days ago, I can assume that there were no purchases from the customer since, and I need to emit (customerId, 0). Does that make sense?
Is it an option to slightly amend the database schema? I suppose now you have something like
(customer_id int, purchases_last_month int)`
Instead how about
`(customer_id int, last_purchase datetime, purchases_last_month int)`
where this time last_purchase is the time of the last purchase made by this customer, and purchases_last_month refers to purchases made in the month before the last one? Then in your DoFn that writes to the database, you'd be making a conditional update (merge/upsert) that updates both last_purchase and purchases_last_month with the values from the current window, but only if last_purchase is increasing. This way you can deal with windows being processed out-of-order or in parallel, at the cost of slight increase in complexity in client queries (which you can address by adding a view on top of the table).
My goal is to add +1 every day to a global variable in Firebase to track how many days have passed. I'm building an app that give new facts every day, and at the 19:00 UTC time marker, I want the case statement number (the day global day variable) to increment by +1.
Some have suggested that I compare two dates and get the days that have passed that way. If I were to do that, I could hard code the initial time when I first want the app to start at 19:00 some day. Then when the function reached1900UTC() is called everyday thereafter, compare it to a Firebase timestamp of that current time which should be 19:00. In theory, it should show that 1 day or more day has passed.
This is the best solution so far, thanks to #DavidSeek and #Jay, but I would still like to figure it out with concurrent writes if anyone has a solution in that front. Until then, I'm marking David's answer as the correct one.
How would I make it so it can't increase more than +1 if multiple people call this? Because my fear is that, when say, 100 people calls this function, it increases by + 1 for every person that has called it.
My app works on a global time, and this function is called every day at 19:00 UTC. So when that function is called I want the day count to increase by one.
You should use transactions to handle concurrent writes:
https://firebase.google.com/docs/database/ios/read-and-write#save_data_as_transactions
You may know this but Firebase doesn't have a way to auto-increment a counter as there's no server side logic, so having a counter increment at 19:00 UTC isn't going to be possible without interaction from a client that happens to be logged on at that time.
That being said, it's fairly straightforward to have the first user that logs in increment that counter - then any other clients logging in after that would not increment it and would have access to that day's new content.
Take a look at Zapier.com - that's a service that can fire time based triggers for your app which may do the trick.
As of this writing, Zapier and Firebase don't play nice together, however, there are a number of other trigger options that Zapier can do with your app while continuing to use Firebase for storage.
One other thought...
Instead of dealing with counters and counting days, why not just have each day's content stored within a node for each day and when each user logs on, the app get's that days content:
2016-10-10
fact: "The Earth is an Oblate Spheroid"
2016-10-11
fact: "Milli Vanilli is neither a Milli or a Vanilli. Discuss."
2016-10-12
fact: "George Washington did not have a middle name"
This would eliminate a number of issues such as counters, updates, concurrent writing to Firebase, triggers etc.
It's also dynamic and expandable and a user could easily see that day's facts or the fact for any prior day(s)
I'm trying to split your question into different sections.
1) If you want to use a global variable to count the days from, let's say, today. Then I would set a timestamp hardcoded into the App that sets the NSDate.
Then In my App, when I need to know the days that have been passed by, I would call a function counting the days from the timestamp to NSDate().
2) If you have a function in your App that counts a +1 into a Firebase, then your fear is correct. It would count +1 for every person that uses the App.
3) If you want every User to have a variable count since when they use their App, then I would handle User registration. So I have a "UserID" and then I would set a Firebase tree like that:
UserID
------->
FirstOpen
-------> Date
That way you could handle each User's first open.
Then you are able to set a timestamp AND call +1 for every user independently. Because then you set the +1 for every user into their UserID .child
I have an events table in my database, which stores a start field (datetime) and a duration field (integer) as well as a unit field (string - Minutes, Hours or Days). In order to derive the end date, I need to add the duration (according to units) to the start. Something like this...
#end = #event.start + (#event.duration).(#event.unit)
I'm just not sure how to accomplish this in Ruby/Rails.
What you're trying to do is:
#event.duration.public_send(#event.unit.downcase)
If you are able to, you may want to store the duration in minutes (as an integer possibly) in your DB or another similar unit and then convert to days or hours for display.
This would make it easier to whitelist the units when storing the data from the user and set up validations to make sure your data is valid.
Also, this will give you extra flexibility, so you can easily have a duration of 1 day 3 hours and 15 minutes if you want to (1,635 minutes) and it will give you the ability to easily sort the events by duration if you want.
I have tasks that my users go through and finish one-by-one and record the result. Depending on the result, the task may have to be put on hold for 'x' number of days, and then after 'x' days, it becomes available again. Sometimes it goes back in the task queue for ONLY 'y' days, and then expires (task.active=0)
What is the best way to achieve this functionality using Rails 3? I am using Postgre.
Make a model attribute inactive_until which is either null or a date in the future. Then add a scope to your model, active, which simply checks if that field is nil or < Time.now
Now to make someone inactive for a time period, set inactive_until to a date in the future.