- ago
I want to place trades on close when the close price creates the signal. I realize the logical problem w/ that; I should get the signal at 3.59 pm and then trade on Close, but I don't want to do that.

How would I do that?

Thank you very much.
1
156
Solved
9 Replies

Reply

Bookmark

Sort
Glitch8
 ( 10.13% )
- ago
#1
In Blocks? Here's how, you need our Power Pack extension. And obviously this Strategy cannot issue any trading signals.

0
Best Answer
- ago
#2
I want it code and it is not on NEXT close. It is the close bar that generates the signal and I want to trade on that CLOSE.

Thank you.
0
Glitch8
 ( 10.13% )
- ago
#3
I understand. That's what the Strategy above does. Did you even try it?
0
Glitch8
 ( 10.13% )
- ago
#4
But let's set some boundaries. In WL you are ALWAYS placing a signals for the NEXT BAR. You cannot place a signal the CURRENT BAR, it just doesn't work that way.

To achieve the result, the Strategy peeks ahead to the next bar. It issues a Buy AT CLOSE order if the RSI if the NEXT BAR closes below 30.

The end result is that you are placing an order at the close of the bar based on information for that bar. This is thanks to the "1 Bar Ahead" Qualifer in Power Pack.

Let me make an example for you in code.
0
Glitch8
 ( 10.13% )
- ago
#6
Here is a coded Strategy that buys AT CLOSE if RSI(4) is below 30 ON THAT BAR, and sells AT CLOSE if RSI(4) is above 70 ON THAT BAR.

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript1 { public class MyStrategy : UserStrategyBase { //create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) {          rsi = RSI.Series(bars.Close, 4);          PlotIndicator(rsi);          StartIndex = 5; } //execute the strategy rules here, this is executed once for each bar in the backtest history public override void Execute(BarHistory bars, int idx) {          //this is important because we're looking 1 bar ahead:     if (idx == bars.Count - 1)             return;     if (!HasOpenPosition(bars, PositionType.Long)) {     //enter at the close if RSI is below 30 this bar     if (rsi[idx + 1] <= 30)                PlaceTrade(bars, TransactionType.Buy, OrderType.MarketClose); } else { //exit at the close if RSI is above 70 this bar     if (rsi[idx + 1] >= 70)                PlaceTrade(bars, TransactionType.Sell, OrderType.MarketClose); } }       //declare private variables below       private RSI rsi; } }
0
- ago
#7
It appears that I am unable to do what I want to do.



The signal is the "arrow" close on the low.

this line:

CODE:
PlaceTrade(bars, TransactionType.Buy, OrderType.MarketClose, 0, 0, "BOC");


Puts the trade on the "following" trade close.


0
- ago
#8
Ok. I have to make the entire strategy "peek" forward by doing idx +1 and idx - 1. I'll work on it.

0
Glitch8
 ( 10.13% )
- ago
#9
Did you even run the sample coded strategy I provided in Post #6? Does it not do what you wanted to do??
0

Reply

Bookmark

Sort