3 registered members (VoroneTZ, monk12, Quad),
829
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Increasing Lots Size
[Re: Qw3rty]
#480889
07/22/20 09:37
07/22/20 09:37
|
Joined: Jun 2019
Posts: 24
Qw3rty
OP
Newbie
|
OP
Newbie
Joined: Jun 2019
Posts: 24
|
Really appreciate the help on this. Also not a developer so I'm bangiing my head every step of the way and reading the maunal as much as posible.
Sample code. How do I reset the Count in the loop to 1.
function run() { set(LOGFILE|PLOTNOW|BALANCE|OPENEND); StartDate = 2016; EndDate = 2017; BarPeriod = 5; LookBack = 5000; LotAmount = 0.1; //1000 or 0.1; vars Prices = series(priceClose(0)); vars SMA100 = series(SMA(Prices,100)); vars SMA30 = series(SMA(Prices,30)); LotAmount = 0.1; Lots = 1; var Count = 1; for(closed_trades) { if (crossOver(SMA30,SMA100)) Count++; else if (crossUnder(SMA30,SMA100)) Count = 1; //Trying to reset counter to 1 for loop but no luck } if(crossOver(SMA30,SMA100)) { enterLong(Count); }
if(crossUnder(SMA30,SMA100)) { enterShort(Count); }
plot("SMA",SMA30,0,RED); plot("SMA",SMA100,0,BLUE); plot("Count",Count,NEW,BLUE); plot("Lots",Lots,NEW,BLUE);
}
I'll take other creative ideas as well.
|
|
|
Re: Increasing Lots Size
[Re: Qw3rty]
#480896
07/22/20 13:36
07/22/20 13:36
|
Joined: Feb 2017
Posts: 1,718 Chicago
AndrewAMD
Serious User
|
Serious User
Joined: Feb 2017
Posts: 1,718
Chicago
|
I am not a developer myself Also not a developer so I'm bangiing my head every step of the way and reading the maunal as much as posible. You just might be a developer if you are: * writing Zorro code and * banging your head on the keyboard. Welcome to the club! If you can write a paragraph explaining how and why you want to increase the lot size, I think I can give better advice. Your ultimate goal is not exactly clear.
|
|
|
Re: Increasing Lots Size
[Re: AndrewAMD]
#480915
07/24/20 07:54
07/24/20 07:54
|
Joined: Jun 2019
Posts: 24
Qw3rty
OP
Newbie
|
OP
Newbie
Joined: Jun 2019
Posts: 24
|
I am not a developer myself Also not a developer so I'm bangiing my head every step of the way and reading the maunal as much as posible. You just might be a developer if you are: * writing Zorro code and * banging your head on the keyboard. Welcome to the club! If you can write a paragraph explaining how and why you want to increase the lot size, I think I can give better advice. Your ultimate goal is not exactly clear. The life of a developer then lol. The above is sample code but the outcome is still the same. I would like to reset the counter or Lot size to 1 for a specific condition when Equity has reached a new high by $X. When trading using crossovers (as an example) one theory is to double down or use the martingale method on your losses to turn them into a profit. This works in theory but the moving average is exactly that, an average of price which isn’t sufficient and there can be unlimited losses and not an unlimited amount of money. With the moving average crossover there is a high and a low before a new cross happens (peak and trough of the trade). What I am trying to achieve is when a trades loses I increase the lot size BUT if the trade wins I might want to increase the lot size depending on if the Equity has reached a new high by X dollars. If a new Equity high is reached then the Lot value (count) moves to 1. Otherwise increase the count by X. If open trade = new equity high then close trade. If open trade <> new equity high then increase lot (regardless of winning or losing trade). I really appreciate all the help. My head really hurts trying to get this right. Let me know if I need to explain further.
|
|
|
Re: Increasing Lots Size
[Re: Qw3rty]
#480920
07/24/20 11:51
07/24/20 11:51
|
Joined: May 2020
Posts: 27 Germany
Morris
Newbie
|
Newbie
Joined: May 2020
Posts: 27
Germany
|
Qw3rty, I must concede I don't fully understand what you are trying to do. But when I look at your for(closed_trades), and you want Count to be reset to 1 and stay there, you might want to add a break statement:
for(closed_trades) {
if (crossOver(SMA30,SMA100)) {
Count++;
} else if (crossUnder(SMA30,SMA100)) {
Count = 1;
break_trades; // to prevent the loop from keeping on counting up
}
}
But then, wouldn't it be more straightforward to re-shuffle like this, since the loop does not affect the result of the if conditions:
if (crossOver(SMA30,SMA100)) {
for(closed_trades) {
Count++; // Or count this elsewhere to avoid the loop
}
} else if (crossUnder(SMA30,SMA100)) {
Count = 1;
}
Again, with the caveat that your intention isn't entirely clear to me...
|
|
|
|