I am trying to set-up my strategy to stop trading if a maximum loss is exceeded and I am having trouble getting this to happen . I can get my program to stop trading if a profit target is reached so I know I am making some wrong assumptions about the sign of numbers . Here is what I have :
// these declared global above pre-main
var MaxProfit = 100;
var MaxLoss = -100;
var Profit = 0;
// in main when trade is exited
if target_hit
{Profit = Profit + (expression to calculate profit of this trade)}
if stop_hit
{Profit = Profit - (expression to calculate loss of this trade)}
if ((Profit <= MaxLoss) || (Profit >= Profit))
// stop trading here and stop taking new signals
I do print statements that show profit of -120 for example and it keeps on trading but if I get a profit of 120 is stops dead in it's tracks and goes to sleep .
Any tips appreciated .
Thanks Bill
// these declared global above pre-main
var MaxProfit = 100;
var MaxLoss = -100;
var Profit = 0;
// in main when trade is exited
if target_hit
{Profit = Profit + (expression to calculate profit of this trade)}
if stop_hit
{Profit = Profit - (expression to calculate loss of this trade)}
if ((Profit <= MaxLoss) || (Profit >= Profit))
// stop trading here and stop taking new signals
I do print statements that show profit of -120 for example and it keeps on trading but if I get a profit of 120 is stops dead in it's tracks and goes to sleep .
Any tips appreciated .
Thanks Bill
Comment