. Thanks a million brother. V/r,
Osito
. Thanks a million brother. You are using an EA that trades one set of signals to hedge trades placed by an EA responding to a different set of signals?orso » Thu Apr 29, 2021 5:32 pm wrote:Hi,
I have a question about hedging....
In order to reduce drawdown with SPB i use hedge function in Desky.
Basically i use SS opposite signal to generate hedge trade.
Now I have this problem: when Desky hedges a basket of trades or a single trade it opens a hedge trade with same lot size of each of them. But if SPB recovers with new position and then market continues to go against my original trade, Desky does not hedge the new position, leaving the basket unbalanced.
Maybe Desky does not hedges (increment hedged lot size) when a hedged trade is already present?
How can i resolve that?
I tried to find something in Desky guide but nothing….
I hope I was clear and didn't ask a stupid question.
Thanks
No.orso » Fri Apr 30, 2021 9:20 pm wrote:I am obliged to use tdesk because you have introduced self-closing of trade hedged on the opposite signal in MPTM.
Furthermore, MPTM does not allow you to selectively manage hedged trades as they all have a different order comment (ticket) unlike those created by Desky and this is a problem in my way of trading.
Dear Steve what I'm telling you, it works, I can prove it, and it also has a rationale.
I posted below the results of the last 2 weeks of one of the many systems I am testing with this configuration.
However, in order not to go off-topic, I ask if the problem that Desky is unable to add hedging trades can be solved.
Thank you]
Code: Select all
double getDifferentialLotSize(string symbol)
{
//Returns a lot size that will ensure that pips movements will
//generate equal profits/losses across all pairs.
//This is a hack of Rene' code at http://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=167116#p167116 - no
//idea how he came up with the calculation.
//Thanks Rene. You are a star as well as a genius.
lotSizeMultiplier = 1.5;
double lotSize = Lot;
double dailyATR = 0;
string atrSymbol = "";
int numATR = 0;
double totalATRProfit = 0.0;
//calculate the average daily ATR of all pairs
for (int pairIndex = 0; pairIndex < ArraySize(TDeskSymbols); pairIndex++)
{
atrSymbol = TDeskSymbols[pairIndex];
getBasics(atrSymbol);//We need factor
dailyATR = iATR( atrSymbol, PERIOD_H1, AtrPeriod, 1 );
if ( !closeEnough(dailyATR, 0 ) )// Only add to totalATRProfit if dailyATR > 0.0
{
totalATRProfit += dailyATR * factor * MarketInfo( atrSymbol, MODE_TICKVALUE );
numATR++;
}//if ( !closeEnough(dailyATR, 0 )
}//for (int pairIndex = 0; pairIndex < ArraySize(TDeskSymbols); pairIndex++)
//calculate the lot size multiplier.
if ( numATR > 0 )
{
getBasics(symbol);
dailyATR = iATR( symbol, PERIOD_H1, AtrPeriod, 1 );
double averageATR = totalATRProfit / numATR;
if ( !closeEnough(dailyATR, 0 ) )
lotSizeMultiplier = averageATR / ( dailyATR * factor * MarketInfo( symbol, MODE_TICKVALUE ) );
}//if ( numATR > 0 ) Code: Select all
#define Builtin_Functn_1 iMA
#define Builtin_Params_1 1,0,MODE_EMA,PRICE_CLOSE
#define Builtin_Functn_2 iMA
#define Builtin_Params_2 240,0,MODE_EMA,PRICE_CLOSE
#define Builtin_Functn_3 iDummy
#define Builtin_Params_3 0,0,0
#define Builtin_Functn_4 iMA
#define Builtin_Params_4 240,1,MODE_EMA,PRICE_CLOSE
double GetBuiltin_1 (string symbol, ENUM_TIMEFRAMES timeframe, int shift) export
{
#ifdef Builtin_Params_1
return(Builtin_Functn_1(symbol,timeframe,Builtin_Params_1,shift));
#else
return(Builtin_Functn_1(symbol,timeframe,shift));
#endif
}
double GetBuiltin_2 (string symbol, ENUM_TIMEFRAMES timeframe, int shift) export
{
#ifdef Builtin_Params_2
return(Builtin_Functn_2(symbol,timeframe,Builtin_Params_2,shift));
#else
return(Builtin_Functn_2(symbol,timeframe,shift));
#endif
}
double GetBuiltin_3 (string symbol, ENUM_TIMEFRAMES timeframe, int shift) export
{
#ifdef Builtin_Params_3
return(Builtin_Functn_3(symbol,timeframe,Builtin_Params_3,shift));
#else
return(Builtin_Functn_3(symbol,timeframe,shift));
#endif
}Check the Experts and Journal tabs when something like this happens. These sometimes reveal the nature of the problem. A divide by zero stops an EA but does not remove it from the chart, so it looks as though it is still working.freakyg415 » Tue May 04, 2021 4:59 am wrote:I was trying to add a Timeframe selections and Multiplier to the ATR for the Differential Lot size option. I have added the options and what I thought was the correct code. Compiled it and recieved 0 warnings, 0 errors, and and all good from the metaeditor however, once I got it onto the chart, It would successfully load and then successfully remove itself.
I use Alerts to show me what is going on. UnderneathSo from there I thought I would keep it basic and could just change out a few bolts under the hood and get Desky to do what I wanted. So I went under and changed the ATR period from D1 to H1 the multiplier to 1.5. I compiled it again and received no issues. I threw it on the chart, and it stayed. I thought I was good to go but when it was time to enter a trade I got punched in the face with the error message you see below
. Can anyone give any advice on moving forward with this? I don't really know where to look because the metaeditor is giving the green light
.
Code: Select all
if ( !closeEnough(dailyATR, 0 ) )
lotSizeMultiplier = averageATR / ( dailyATR * factor * MarketInfo( symbol, MODE_TICKVALUE ) );
Code: Select all
Alert(symbol," ",stype,": price ", DoubleToString(price, digits), ": Lot ", lotsize, ": TP ", DoubleToString(take, digits),
": SL ", DoubleToString(stop, digits) );
Code: Select all
extern string hls="-- 'Hard' lot sizing --";
extern double Lot=0.1;Code: Select all
double lotSize = Lot;