Coding help - page 246

 
macerina:
Thank you Mladen for the code ... Does this have the double macd comparision and 50 crossover as you have explained in the previous logic. Thanks in advance

macerina

The difference is that in the aspen graphic version secondary entry signal is a cross of rsi and its signal line, while in metatrader version secondary signal is a cross of rsi of a 50 line. Macd part is the same (you should take the closed bar signal - that is the way how it s done in the aspen graphics version)

 

thanks for the info mladen ... is it possible to set option in the same indicator for selecting 50 line cross and signal line cross ...

Thanks in Advance

 
mladen:
sulaimoney All is OK with those procedures. Attaching a simple indicator that is showing that all is OK when the calls to those twor procedures is executed one after the other. Check the rest of the code since the error is not in those two procedures

Hello Mladen

Ive checked through the code and i found some errors which ive replaced.

Now I'm trying to use the value of

double lastorderprice = 0;

And

int bscount = 0;

As variables on a global scope wirhin the ea such that they can be called from e.g void NewOrder()

// OnEveryTick

void LastBuySellOrder() // Loops through all open order to select last order(buy/sell) OnEveryTick

{

double lastorderprice = 0;

datetime lastTime = 0;

datetime closeTime = 0;

int lastTicket = -1; // None open.

for (int i=OrdersTotal()-1; i >= 0; i--)

if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))

{

if (OrderSymbol() == Symbol() && OrderMagicNumber() == OrderId

&&( OrderType() == OP_BUY || OrderType() == OP_SELL )

&& OrderOpenTime() >= lastTime && OrderCloseTime() == closeTime

&& OrderTicket() > lastTicket )

{

lastTime = OrderOpenTime();

lastorderprice = OrderOpenPrice();

closeTime = OrderCloseTime();

lastTicket = OrderTicket();

}

return(lastTicket);

}

else

Print("OrderSelect() error - ", ErrorDescription(GetLastError()));

}

void PendingStopOrderCount()

{

int bscount = 0;

for (int i=OrdersTotal()-1; i >= 0; i--)

if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))

{

if (OrderSymbol() == Symbol())

if (OrderMagicNumber() == OrderId)

if (OrderType() == OP_BUYSTOP )

{

bscount++;

}

}

else

{

Print("OrderSend() error - ", ErrorDescription(GetLastError()));

}

}

// If OpBuy Or OpSell exist

void NewOrder()

{

if (bscount==0)

{

BuyStopPending();

}

}

 

HI

This indicator is repainter? If yes when how much bars back??

xps_v8_oscillator.ex4xps_v8_oscillator.mq4

 
toldmikl:
HI

This indicator is repainter? If yes when how much bars back??

xps_v8_oscillator.ex4xps_v8_oscillator.mq4
Yes. It is a solar winds indicator with periods set automatically depending on the time frame :

1 minute : period = 2880

5 minute : period = 576

15 minute : period = 192

30 minute : period = 96

1 hour and above: period = 48

 

OK but I use this on offline chart M2 :S So it's not normal Timeframe

 
toldmikl:
OK but I use this on offline chart M2 :S So it's not normal Timeframe

Try it out and you shall see for yourself (use something like autorefresh to force the indicator to refresh all the bars from or simply, when enough new bars are built, go to parameters , do not change anything and click OK). Pay attention to the periods when the trend changes what will it do.

Better than me trying to explain what is wrong ind solar winds code and to convince anybody

 

I can't change period only I can see source code here is it:

#property indicator_separate_window

#property indicator_minimum 0

#property indicator_maximum 1

#property indicator_buffers 3

#property indicator_color2 C'72,49,255'

#property indicator_color3 C'255,49,72'

#property indicator_width2 6

#property indicator_width3 6

int period;

extern bool alarm=false;

double ExtBuffer0[];

double ExtBuffer1[];

double ExtBuffer2[];

double alertBar;

double last;

int init() {

//-----------------------------

switch ( Period() )

{

case 1: period = 2880;break;

case 5: period = 576;break;

case 15: period = 192;break;

case 30: period = 96;break;

case 60: period = 48;break;

case 240: period = 48;break;

case 1440: period = 48;break;

case 10080: period = 48;break;

default : period = 48;break;

}

//-----------------------------

SetIndexStyle(0,DRAW_NONE);

SetIndexStyle(1,DRAW_HISTOGRAM);

SetIndexStyle(2,DRAW_HISTOGRAM);

IndicatorDigits(Digits+1);

SetIndexBuffer(0,ExtBuffer0);

SetIndexBuffer(1,ExtBuffer1);

SetIndexBuffer(2,ExtBuffer2);

IndicatorShortName("");// X :-)");

SetIndexLabel(0, NULL);

SetIndexLabel(1, NULL);

SetIndexLabel(2, NULL);

return(0);

}

int deinit()

{

//----

ObjectDelete("XPS");

ObjectDelete("XPS2");

ObjectDelete("XPS3");

//----

return(0);

}

int start() {

int limit;

int counted_bars=IndicatorCounted();

double prev,current,old;

double Value=0,Value1=0,Value2=0,Fish=0,Fish1=0,Fish2=0;

double price;

double MinL=0;

double MaxH=0;

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

for(int i=0; i<limit; i++)

{ MaxH = High;

MinL = Low[Lowest(NULL,0,MODE_LOW,period,i)];

price = (High+Low)/2;

Value = 0.33*2*((price-MinL)/(MaxH-MinL)-0.5) + 0.67*Value1;

Value=MathMin(MathMax(Value,-0.999),0.999);

ExtBuffer0=0.5*MathLog((1+Value)/(1-Value))+0.5*Fish1;

Value1=Value;

Fish1=ExtBuffer0;

}

bool up = TRUE;

for(i=limit-2; i>=0; i--)

{

current=ExtBuffer0;

prev=ExtBuffer0;

if (((current0))||(current<0)) up= false;

if (((current>0)&&(prev0)) up= true;

if(!up) {

ExtBuffer2=1;

ExtBuffer1=0;

if (alarm && i==0 && last != 2 && ExtBuffer1 == 0 && Bars>alertBar)

{

Alert("OSC... Possible Trend going DOWN on ",Period()," ",Symbol());

alertBar = Bars;last = 2;

}

}

else {

ExtBuffer1=1;

ExtBuffer2=0;

if (alarm && i==0 && last != 1 && ExtBuffer2 == 0 && Bars>alertBar)

{

Alert("OSC... Possible Trend going UP on ",Period()," ",Symbol());

alertBar = Bars;

last = 1;

}

}

}//End Loop

ObjectDelete("XPS");

ObjectCreate("XPS", OBJ_LABEL, 2, 0, 0);

ObjectSetText("XPS","!XPS v8", 28, "Arial Black", C'46,46,46');

ObjectSet("XPS", OBJPROP_CORNER, 2);

ObjectSet("XPS", OBJPROP_BACK, 0);

ObjectSet("XPS", OBJPROP_XDISTANCE, 6);

ObjectSet("XPS", OBJPROP_YDISTANCE, 8);

ObjectDelete("XPS2");

ObjectCreate("XPS2", OBJ_LABEL, 2, 0, 0);

ObjectSetText("XPS2","!XPS v8", 28, "Arial Black", Silver);

ObjectSet("XPS2", OBJPROP_CORNER, 2);

ObjectSet("XPS2", OBJPROP_BACK, 0);

ObjectSet("XPS2", OBJPROP_XDISTANCE, 4);

ObjectSet("XPS2", OBJPROP_YDISTANCE, 10);

ObjectDelete("XPS3");

ObjectCreate("XPS3", OBJ_LABEL, 2, 0, 0);

ObjectSetText("XPS3","Trade like a BOSS", 9, "Arial Black", Silver);

ObjectSet("XPS3", OBJPROP_CORNER, 2);

ObjectSet("XPS3", OBJPROP_BACK, 0);

ObjectSet("XPS3", OBJPROP_XDISTANCE, 7);

ObjectSet("XPS3", OBJPROP_YDISTANCE, 3);

return(0);

}

So?

 
toldmikl:
I can't change period only I can see source code here is it:

#property indicator_separate_window

#property indicator_minimum 0

#property indicator_maximum 1

#property indicator_buffers 3

#property indicator_color2 C'72,49,255'

#property indicator_color3 C'255,49,72'

#property indicator_width2 6

#property indicator_width3 6

int period;

extern bool alarm=false;

double ExtBuffer0[];

double ExtBuffer1[];

double ExtBuffer2[];

double alertBar;

double last;

int init() {

//-----------------------------

switch ( Period() )

{

case 1: period = 2880;break;

case 5: period = 576;break;

case 15: period = 192;break;

case 30: period = 96;break;

case 60: period = 48;break;

case 240: period = 48;break;

case 1440: period = 48;break;

case 10080: period = 48;break;

default : period = 48;break;

}

//-----------------------------

SetIndexStyle(0,DRAW_NONE);

SetIndexStyle(1,DRAW_HISTOGRAM);

SetIndexStyle(2,DRAW_HISTOGRAM);

IndicatorDigits(Digits+1);

SetIndexBuffer(0,ExtBuffer0);

SetIndexBuffer(1,ExtBuffer1);

SetIndexBuffer(2,ExtBuffer2);

IndicatorShortName("");// X :-)");

SetIndexLabel(0, NULL);

SetIndexLabel(1, NULL);

SetIndexLabel(2, NULL);

return(0);

}

int deinit()

{

//----

ObjectDelete("XPS");

ObjectDelete("XPS2");

ObjectDelete("XPS3");

//----

return(0);

}

int start() {

int limit;

int counted_bars=IndicatorCounted();

double prev,current,old;

double Value=0,Value1=0,Value2=0,Fish=0,Fish1=0,Fish2=0;

double price;

double MinL=0;

double MaxH=0;

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

for(int i=0; i<limit; i++)

{ MaxH = High;

MinL = Low[Lowest(NULL,0,MODE_LOW,period,i)];

price = (High+Low)/2;

Value = 0.33*2*((price-MinL)/(MaxH-MinL)-0.5) + 0.67*Value1;

Value=MathMin(MathMax(Value,-0.999),0.999);

ExtBuffer0=0.5*MathLog((1+Value)/(1-Value))+0.5*Fish1;

Value1=Value;

Fish1=ExtBuffer0;

}

bool up = TRUE;

for(i=limit-2; i>=0; i--)

{

current=ExtBuffer0;

prev=ExtBuffer0;

if (((current0))||(current<0)) up= false;

if (((current>0)&&(prev0)) up= true;

if(!up) {

ExtBuffer2=1;

ExtBuffer1=0;

if (alarm && i==0 && last != 2 && ExtBuffer1 == 0 && Bars>alertBar)

{

Alert("OSC... Possible Trend going DOWN on ",Period()," ",Symbol());

alertBar = Bars;last = 2;

}

}

else {

ExtBuffer1=1;

ExtBuffer2=0;

if (alarm && i==0 && last != 1 && ExtBuffer2 == 0 && Bars>alertBar)

{

Alert("OSC... Possible Trend going UP on ",Period()," ",Symbol());

alertBar = Bars;

last = 1;

}

}

}//End Loop

ObjectDelete("XPS");

ObjectCreate("XPS", OBJ_LABEL, 2, 0, 0);

ObjectSetText("XPS","!XPS v8", 28, "Arial Black", C'46,46,46');

ObjectSet("XPS", OBJPROP_CORNER, 2);

ObjectSet("XPS", OBJPROP_BACK, 0);

ObjectSet("XPS", OBJPROP_XDISTANCE, 6);

ObjectSet("XPS", OBJPROP_YDISTANCE, 8);

ObjectDelete("XPS2");

ObjectCreate("XPS2", OBJ_LABEL, 2, 0, 0);

ObjectSetText("XPS2","!XPS v8", 28, "Arial Black", Silver);

ObjectSet("XPS2", OBJPROP_CORNER, 2);

ObjectSet("XPS2", OBJPROP_BACK, 0);

ObjectSet("XPS2", OBJPROP_XDISTANCE, 4);

ObjectSet("XPS2", OBJPROP_YDISTANCE, 10);

ObjectDelete("XPS3");

ObjectCreate("XPS3", OBJ_LABEL, 2, 0, 0);

ObjectSetText("XPS3","Trade like a BOSS", 9, "Arial Black", Silver);

ObjectSet("XPS3", OBJPROP_CORNER, 2);

ObjectSet("XPS3", OBJPROP_BACK, 0);

ObjectSet("XPS3", OBJPROP_XDISTANCE, 7);

ObjectSet("XPS3", OBJPROP_YDISTANCE, 3);

return(0);

}

So?

It is applying period 48 for any time frame that is not a standard time frame (like "2 minutes" offline charts)

For versions of solar winds for which you can change the calculation period, see this thread : https://www.mql5.com/en/forum/179650

 

Greetings to you gurus, Please help me edit this script and leave ONLY order, lot size, buy/sell. I already own an EA that places take profit/stop loss automatically thereby conflicting with that indy.

This script automatically opens any numbers of market order you specified at MENU at once but currently it just opened only one order even if you input 5 orders. Please help me fix this ERROR and DELETE completely take profit/stop loss from SCRIPT

Bless you

Reason: