114; Randomize History Data

Hi , are u sure that this snippet is calculated correctly? 

private double atrValue = 0;
private int atrPeriod = 14,





These instance parameters are not used in a method where should be these two variables used. I bet that i has to to something with globalATR in method parameter :


modifyData(IRandomGenerator rng, TickEvent tickEvent, double globalATR)



... im trying to modify script and change theese parameters does nothing....

/*
* Copyright (c) 2017-2018, StrategyQuant - All rights reserved.
*
* Code in this file was made in a good faith that it is correct and does what it should.
* If you found a bug in this code OR you have an improvement suggestion OR you want to include
* your own code snippet into our standard library please contact us at:
*
* This code can be used only within StrategyQuant products.
* Every owner of valid (free, trial or commercial) license of any StrategyQuant product
* is allowed to freely use, copy, modify or make derivative work of this code without limitations,
* to be used in all StrategyQuant products and share his/her modifications or derivative work
* with the StrategyQuant community.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package SQ.MonteCarlo.Retest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.strategyquant.lib.*;
import com.strategyquant.datalib.*;
import com.strategyquant.tradinglib.*;

@ClassConfig(name="Randomize history data", display="Randomize history data, with probability #Probability# % and max price change #MaxChange# % of ATR")
@Help("<b>Note!</b>If you choose this option then robustness tests will be tested with Selected Timeframe precision, while original strategy will be tested with configured precision.<br/>This might cause difference in results between original strategy and simulations because of different precision.<br/>To avoid this, use Selected Timeframe precision in Setings : Data.")
public class RandomizeHistoryData extends MonteCarloRetest {
    public static final Logger Log = LoggerFactory.getLogger(RandomizeHistoryData.class);
    
    @Parameter(name="Probability", defaultValue="20", minValue=1, maxValue=100, step=1)
    public int Probability;
    
    @Parameter(name="Max change", defaultValue="10", minValue=1, maxValue=100, step=1)
    public int MaxChange;
    
    private int barsProcessed = 0;
    private double atrValue = 0;
    private int atrPeriod = 14;
    
    //------------------------------------------------------------------------
    //------------------------------------------------------------------------
    //------------------------------------------------------------------------

    public RandomizeHistoryData() {
        super(MonteCarloTestTypes.ModifyData);
    }
    
    //------------------------------------------------------------------------

    public void modifyData(IRandomGenerator rng, TickEvent tickEvent, double globalATR) {
        double dblProbability = ((double) Probability/ 100.0d);
        
        if(rng.probability(dblProbability)) {
            // we should change this price
            double ask = tickEvent.getAsk();
            double bid = tickEvent.getBid();
            double spread = ask - bid;
            
            int change = rng.nextInt(MaxChange);
            
            double dblChange = ((double) change)/ 100.0d;

            double priceChange = 2 * globalATR * dblChange;
            
            bid = (rng.nextInt(2) == 0 ? bid + priceChange : bid - priceChange);
            
            tickEvent.setBid(bid);
            tickEvent.setAsk(bid + spread);
        }
    }


}
Attachments
No attachments
  • Votes 0
  • Project StrategyQuant X
  • Type Bug
  • Status Refused
  • Priority Normal

History

IH
#1

clonex / Ivan Hudec

21.11.2018 21:07

Task created

TT
#2

Tamas

23.11.2018 07:30

Status changed from New to Refused

Above mentioned variables are not used in the snippet. It is ok.

Votes: 0

Drop files to upload

or

choose files

Max size: 5MB

Not allowed: exe, msi, application, reg, php, js, htaccess, htpasswd, gitignore

...
Wait please