I am trying to use the not so easy , easy language to talk computer from the land down under ! The main aim for this post is to try and understand the relationships needed for money management and the code in the signals to all talk (the same language) , together. I am using multicharts 64. Using end of day metastock data.
I am having some trouble getting this code to work in the portfolio trader , as the money management signal ? All im trying to do is the standard 1% rule , and have my trading float of 40k and use a 1% trade size calculation. Use of these settings in the portfolio trader do not work for me. I have been clicking away for days and looking at the manuals , but I have to admit that for me even the manual is a bit hard to interpret. It would be great if there was some super basic prebuilt system in MC that we can actually see what goes where , link the dots so to speak.
Code: Select all
//money management
variables: entryprice(0) , stoplosslevel(1), stopvalue(2), accountvalue(3), risk(4), Qtyshares(5), positionsize(6);
// entry price
entryprice = close;
//stop loss level
stoplosslevel = close - low[1];
//Stop Value
stopvalue = entryprice-stoplosslevel;
//Available funds for trading
accountvalue = 40000;
//Risk 1% of 40k
risk = 40000*1/100;
//quatity of shares
Qtyshares = risk / stopvalue ;
//Position size value
positionsize = Qtyshares * entryprice;
The code i am trying to use is below. I dont know how to fix this yet either. Again many days trying different types, I tried with variables too but not able to get that to work properly too. . The signals are not right on a chart, but a couple are. It seems that the first condition is always right. And the second condition is not being triggered. And the third condition is always right. However , the third condition is starting at the first and not at the second condition as it should. See screen shot.
The basic principal was
condition 1 to buy a breakout
condition 2 was a small dip in price action
Then after the dip, condition 3 would exit
Nothing spectacular , but if I can get my head around how all this looks, and works , im sure I will be on my way to building something more involved. Still need stop losses and work out how to get trade management to get position size from my actual account float value as it changes, but one step at a time. This is just a basic example to get started.
Code: Select all
//buy signal
condition1 = low > low[1] And low [2] > low[1] and close > High[1];
if condition1 then
buy this bar at close ;
//Intermitent condition trigger
condition2 = low > low[1] And low [2] > low[1];
//sell condition
condition3 = close < low[1];
//sell signal
if condition1 then begin
condition2 ;
end;
if condition2 then begin
condition3;
end;
If condition3 then
sell this bar at close ;
Again my main aim is to try and get a basic thing to work, so i can understand how it ALL works. I really appreciate any help you can give.
Cheers
Morgz