The indicator repaints, it paints a green/red marker and then signals an alert when confirmed by the next bar. Even in sideways markets its not that bad, however I will hopefully have set time frames or filter with another indicator. Well, thats if i can get the bloody code slightly right with assistance from you fine people :-)
B.T.W. it seems to me that you are acting against the trend (IMHO it's supposed to be upside)
#property strict// #include <stdlib.mqh> why do you need this file includedexternint dist2=6;
externint SignalBar=2;
inputdouble lots=3;
inputdouble sl=600;
inputdouble tp=1200;
externint MagicNumber=45645;
int Buy_Pos = 0, Sell_Pos = 0;
int ticket;
//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
//---//---return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Expert deinitialization function |//+------------------------------------------------------------------+voidOnDeinit(constint reason)
{
//---//---
}
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
//---// Alert(MarketInfo(Symbol(), MODE_STOPLEVEL)); what the heck you need this linefor(int i = OrdersTotal() -1; i >= 0; i--)
{
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
{
if (OrderType() == OP_BUY)
{
Buy_Pos++;
}
if (OrderType() == OP_SELL)
{
Sell_Pos++;
}
}
}
bool uptrend=iCustom(NULL,0,"super_signals_v2_alert",1,1)!=EMPTY_VALUE;
bool downtrend=iCustom(NULL,0,"super_signals_v2_alert",0,1)!=EMPTY_VALUE;
Comment(uptrend," ",downtrend); //for what reason you need this line//especially when it's gonna write you//"false true", or "true true" or "false false"if(uptrend && Sell_Pos == 0)
{
ticket = OrderSend(Symbol(), OP_SELL, lots, Bid, 3, Ask + sl * Point, Ask - tp * Point,NULL, MagicNumber,0, Red);
if (ticket < 0)
Alert("Can't open Sell Order, Error code ", GetLastError());
//Sleep(20000); // why in the world you need this line
}
if(downtrend && Buy_Pos == 0)
{
ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, 3, Bid - sl * Point, Bid + tp * Point,NULL, MagicNumber, 0, Blue);
if (ticket < 0)
Alert("Can't open Buy Order, Error code ", GetLastError());
//Sleep(20000); // why in the world you need this line
}
//---
}
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
The plan is to have it open close trades like this.
Any ideas how to get this to work in this code? I really appreciate your help, i finally feel like im getting somewhere
don't forget to cover all the possibilities as described in the picture
As you have indicated, if a buy position is already open, another buy signal is ignored. i.e only one position per direction. Same for the short.
The code I have does not enter positions as i want it to, it enters them as follows...
here is the code i have : can anyone assist
you have to add a condition
if(uptrend && another_order_is_not_open)in this case you have to loop all the orders to find out if another order is open
same for downtrend
if(downtrend && another_order_is_not_open)already told you once you have to fix you code like before
I did, same problem. Ive been moving the code around trying different things with no joy.
I did, same problem.
no you didn't and you don't listen
i wrote:
you have to add a condition
if(uptrend && another_order_is_not_open)in this case you have to loop all the orders to find out if another order is open
same for downtrend
if(downtrend && another_order_is_not_open)and i don't see it in your code
i wrote:
already told you once you have to fix you code like before
and i don't see it either
so here we go:
B.T.W. it seems to me that you are acting against the trend (IMHO it's supposed to be upside)