Reputation: 77
I've been trading with grid orders for some time now, but just realized there is a WindowPriceOnDropped()
function that I'd like to incorporate.
My standard order placement is written like this. Here is sample code for 5 orders spaced 5 pips apart, all micro lots, with 50 pip stops and 100 pip take profits. The first order appears close to market, just 1 pip down, and the rest follow:
int start()
{
int ticket;
double point;
//----
point=MarketInfo(Symbol(),MODE_POINT);
//----
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.01,Ask-100*point,0,Ask-600*point,Ask+900*point,"[5] 1k, 1 pip down");
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.01,Ask-150*point,0,Ask-650*point,Ask+850*point,"[5] 1k, 1 pip down");
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.01,Ask-200*point,0,Ask-700*point,Ask+800*point,"[5] 1k, 1 pip down");
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.01,Ask-250*point,0,Ask-750*point,Ask+750*point,"[5] 1k, 1 pip down");
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.01,Ask-300*point,0,Ask-800*point,Ask+700*point,"[5] 1k, 1 pip down");
//----
return(0);
}
//+------------------------------------------------------------------+
I'm testing WindowPriceOnDropped()
, like this:
#include <stdlib.mqh>
#include <WinUser32.mqh>
int start()
{
int ticket;
double point;
double Price = WindowPriceOnDropped();
//----
point=MarketInfo(Symbol(),MODE_POINT);
//----
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.01,Price*point,0,Price-500*point,Price+1000*point, "[5] 1k test");
//----
return(0);
}
//+------------------------------------------------------------------+
However, the order doesn't appear at all. Am I missing something? The only thing I've changed is "Price", which ought to store the point value on drop due to the WindowPriceOnDropped()
function, as opposed to Ask minus point value. Why can't I simply substitute the variable for "Ask" if the logic remains the same?
Thank you.
Upvotes: 0
Views: 111
Reputation: 4681
WindowPriceOnDropped()
returns a normalized value of the price, you can normalize again with NormalizeDouble(double, _Digits)
. So instead of Price*point
use just Price
or its normalized value.
Upvotes: 0