Create custom block?
-
I read some about custom block in foum, but how create one function return true o false and recieve constant params?
bool RSISellCheck(int Loc)
{
double RSIMain = iRSI(Symbol(),0,RSIPeriod,PRICE_CLOSE,Loc);
if(RSIMain < 50) return(false);
for(int x=Loc;x<=Loc+2;x++)
{
if(High[x]>High[Loc])return(false);
}
for(int y=Loc+4;y<(Loc+CandlesBack);y++)
{
if(High[y]>High[Loc]) break;
int s=y;
for(int z=y-2;z<=y+2;z++)
{
if(High[z]>High[y]){y++; break;}
}
if(s!=y){y--; continue;}
bool OB=false;
for(int k=Loc;k<=y;k++)
{
double RSIOB = iRSI(Symbol(),0,RSIPeriod,PRICE_CLOSE,k);
if(RSIOB>70) {OB=true; break;}
}
if(OB==false) continue;
double Mom1=iMomentum(Symbol(),0,MomentumPeriod,PRICE_CLOSE,Loc);
double Mom2=iMomentum(Symbol(),0,MomentumPeriod,PRICE_CLOSE,y);
if(Mom1>Mom2) continue;
LastKDS=y;
return(true);
}
return(false);
} -
here is more than one way how to do this ... you can add this function here into functions:
https://fxdreema.com/studio
than call this function one time with custom code block:

and now you can working with this function .. but I see here some variables which must be defined before this function or in Constants or Variables ... like: "CandlesBack" ...second way can be little complicated and need again custom code:

here are also variables and constants as inputs:


https://fxdreema.com/shared/9mz6YkCoemaybe exist something easier, but I was using it as examples above are described ...
-
Thank miro1360 for your work. You read, understand my function and modificate, Your example is perfect for me. You make very work for this response. Excuxe my English, but I am very grateful.
-
What did I do wrong?
No open trades.
https://fxdreema.com/shared/fii7scMJd -
... my answer with return in this function was not right

try this modification:https://fxdreema.com/shared/Omfgtqdqd

next ... blocks Check profit unrealized - when you set filters for "both" buy and sells, it counts profit from buy and sell together ... when you will separate it, set here filter only for buy (or only for sell) ... because when you open it in hedge (buy+sell) your profit is 0-spread and it will not be closed ...
-
Thank, I make the corrections. For now I disabled helding. I have new dude.
https://fxdreema.com/shared/C7ORRhFXcI pretend open second trader the same type a first trade, if prive go loss profit the X pip, in this case 70pip.
Example:
level 1: open trade eurusd, 5m, price: 1.06700, type: buy with lot: 0.01
when price is 1.06000 level 2 activate and open other type buy order with lot 0.03
when profit the trade level 1 and trade level 2 it positive, more or less 1.06500 close level 1 trade in loss , and level 2 trade in profit.but pip away from open price block, I think do diference, it active when price up, no when price down in this example, how I repair this code?
-
with pink block use Dark pink block before ... because it select trade and than you can work with selected trade ...

... and for opposite direction (trade in loss) give Pips_To_Trade_Second as negative value ...
-
thank you, I make correction now, It very easy, but I don´t know negative numbers.
-
I mean as input try it while testing ...
Pips_To_Trade_Second = 20 --- is possitive
Pips_To_Trade_Second = -20 --- is negative (opposite direction) -
New version
https://fxdreema.com/shared/4gOK5oQE
on Trade tab, block 181. I try create message for coment block id 38, in update stats block I try update varible+1, when close each type trades. The values always 0, what does i wrong?Level 3 I try open oposite trades a open trade level 1 and open trade level 2, very soon i show finish.
-
In comment block, I put trade close, don´t work, it is posible, I haven´t same pre block, for use this information?
-
I have not good understood your question ....
-
I explain other form, excuse my bad english.
In block 177, I try update variables, but no update, What did I do wrong? Variables always 0, I show variable with comment block
https://fxdreema.com/shared/LPgRRDA5b -
send here please example with lower amount of blocks where it is not working (which shows your issue) because when is here a lot of blocks, I have not enough time to study all where can be problem
