PureBytes Links
Trading Reference Links
|
Thanks, nice to hear.
Thomas
www.PatternExplorer.com
Von: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] Im Auftrag
von cristianc22
Gesendet: Sonntag, 27. Jänner 2008 00:49
An: amibroker@xxxxxxxxxxxxxxx
Betreff: [amibroker] Re: Loop within loop
Thank you Thomas,
I got your file. It is working perfectly. It does what I need it to
do. I am running some optimizing now with different stoploss and
target prices.
--- In amibroker@xxxxxxxxxxxxxxx, "Thomas Z." <tzg@xxx> wrote:
>
> Hello Christian,
>
> i've sent it to your private mail address.
>
>
> Thomas
> www.PatternExplorer.com
>
>
> Von: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]
Im Auftrag
> von cristianc22
> Gesendet: Samstag, 26. Jänner 2008 20:14
> An: amibroker@xxxxxxxxxxxxxxx
> Betreff: [amibroker] Re: Loop within loop
>
> Hello Thomas,
> Thank you for the quick reply. I could not open the attachment. I
> think Yahoo removed the file from your message.
> Can you please attach the file to the files area of the yahoo
group,
> or send it directly to my email address. I will try to just copy
and
> paste for now.
> I'll let you know how it works.
>
> Thanks again,
> Cristian
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Thomas Z." <tzg@> wrote:
> >
> > Hello,
> >
> > i have modified your code and removed the k-loop which makes it
> easier. I
> > haven't fully checked everything but it seems to work correct.
> Slippage
> > needs to be implemented.
> > Let me know if it works as expected. I have added shapes and a
stop
> line.
> >
> > Buy = 0;
> > Sell = 0;
> > Stop = Null;
> > StopArray = Null;
> >
> > EntryLongSignal = Cross(MA(C, 5), MA(C, 20));
> > ExitLongPosition = L == LLV(L, 20);
> > TakeProfit = 10 * ATR(10);
> > BreakevenMove = 2 * ATR(10);
> > StopLossAmount = 2 * ATR(10);
> >
> > for (i = 1; i < BarCount; i++)
> > {
> > if (EntryLongSignal[i])
> > {
> > Buy[i] = 1;
> > BuyPrice[i] = O[i];
> >
> > for (j = i; j < BarCount; j++)
> > {
> > if (j > i)
> > Buy[j] = 0;
> >
> > // Calc stop
> > if (j == i)
> > Stop = BuyPrice[i] - StopLossAmount
> [i];
> > else
> > if (H[j-1] >= BuyPrice[i] +
> > BreakevenMove[i])
> > Stop = BuyPrice[i];
> >
> > StopArray[j] = Stop;
> >
> > if (ExitLongPosition[j-1] AND j > i) // Sell
> next
> > bar at open
> > {
> > Sell[j] = 1;
> > SellPrice[j] = O[j];
> > Stop = Null;
> > i = j;
> > break;
> > }
> > else
> > if (L[j] <= Stop) // Check stop
> > {
> > Sell[j] = 1;
> > SellPrice[j] = Stop;
> > Stop = Null;
> > i = j;
> > break;
> > }
> > else
> > if (H[j] >= BuyPrice[i] +
> > TakeProfit[i]) // Check take profit
> > {
> > Sell[j] = 1;
> > SellPrice[j] =
> BuyPrice[i] +
> > TakeProfit[i];
> > Stop = Null;
> > i = j;
> > break;
> > }
> > else
> > if (j == BarCount -
> 1)
> > {
> > Stop = Null;
> > i = j;
> > break;
> > }
> > }
> > }
> > }
> >
> > Plot(C, "Close", 1, 128);
> > Plot(StopArray, "Stop", colorGreen, 1);
> > PlotShapes(Buy * shapeUpArrow, colorGreen, 0, L, -12);
> > PlotShapes(Sell * shapeDownArrow, colorRed, 0, H, -12);
> >
> >
> > Thomas
> > www.PatternExplorer.com
> >
> >
> > Von: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]
> Im Auftrag
> > von cristianc22
> > Gesendet: Samstag, 26. Jänner 2008 16:13
> > An: amibroker@xxxxxxxxxxxxxxx
> > Betreff: [amibroker] Loop within loop
> >
> > Hello,
> > I am trying to create a loop for my stops. I found a lot of good
> > examples in the previous postings.
> > The "j" loop works well without adding the "k" loop.
> > The idea is to have the stop moved at breakeven when the market
> moves
> > in my favor.
> > The idea is simple. One fixed stoploss point, one profit target
> point
> > and stoploss point moved after a certain profit.
> > I would appreciate any suggestions.
> > In other words - How do I escape from loop k and go back to loop
j?
> > (I don't know if yahoo will let me keep the formating)
> >
> > for (i = 1; i < BarCount; i++)
> > {
> > if (EntryLongSignal[ i ])
> > {
> > Buy[ i ] = 1;
> > BuyPrice[ i ] = O[ i ];
> > for (j = i + 1; j < BarCount; j++)
> > {
> > if (L[ j ] <= (BuyPrice[ i ]-StopLoss))
> > {
> > Sell[ j ] = 1;
> > SellPrice[ j ] = BuyPrice[ i ]-StopLoss;
> > i = j;
> > j = BarCount;
> > }
> > else if (H[ j ] >= (BuyPrice[ i ] +
> > BreakevenMove))
> > {
> > for (k = j + 1; k < BarCount; k++)
> > {
> > if (L [ k ] <= BuyPrice [ i ] + 0.0002)
> > {
> > Sell[ k ] = 1;
> > SellPrice[ k ] = BuyPrice[ i ];
> > j = k;
> > k = BarCount;
> > }
> > else if (H[ k ] >= BuyPrice[ i ] +
> > TakeProfit)
> > {
> > Sell[ k ] = 1;
> > SellPrice[ k ] = BuyPrice[ i ] +
> > TakeProfit;
> > j = k;
> > k = BarCount;
> > }
> > }
> > }
> > else if (ExitLongPosition[ j ])
> > {
> > Sell[ j ] = 1;
> > SellPrice[ j ] = O[ j ];
> > i = j;
> > j = BarCount;
> > }
> > else if (j == BarCount - 1)
> > {
> > Buy[ i ] = 0;
> > i = BarCount;
> > }
> >
> > }
> >
> > }
> >
> > }
> >
>
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|